#pragma once
#include <map>
#include <memory>
#include <string>

namespace perception::camera {

enum class ErrorCode {
    E_OK = 0,
    E_AUTH_FAIL = 101
};

enum class ObjectMajorType {
    UNKNOWN = 0,
    UNKNOWN_MOVABLE = 1,
    UNKNOWN_UNMOVABLE = 2,
    PEDESTRIAN = 3,
    BICYCLE = 4,
    VEHICLE = 5,
    MAX_OBJECT_TYPE = 6,
};

enum class ObjectType {
    UNKNOWN = 0,
    UNKNOWN_MOVABLE = 1,
    UNKNOWN_UNMOVABLE = 2,
    CAR = 3,
    VAN = 4,
    TRUCK = 5,
    BUS = 6,
    CYCLIST = 7,
    MOTORCYCLIST = 8,
    TRICYCLIST = 9,
    PEDESTRIAN = 10,
    TRAFFICCONE = 11,
    SAFETY_TRIANGLE = 12,
    BARRIER_DELINEATOR = 13,
    BARRIER_WATER = 14,
    ANIMAL = 15,
    MAX_OBJECT_TYPE = 16,
};

enum class CameraTypeBroad {
    MONOCULAR = 0, //(单目)枪式
    FISHEYE = 1, // 鱼眼
    OTHERS = 2,
    MAX_BROAD_TYPE = 3,
};

// @brief object template sort type
enum class TemplateSortType {
    BY_HEIGHT = 0, // 升序
    BY_WIDTH = 1,
    BY_LENGTH = 2,
    BY_HEIGHT_DESC = 3, // 降序
    BY_WIDTH_DESC = 4,
    BY_LENGTH_DESC = 5,
    MAX_TEMPLATE_SORT_TYPE = 6,
};

const std::map<ObjectType, ObjectMajorType> ObjectTypeMapMajorType = {
    { ObjectType::CAR, ObjectMajorType::VEHICLE },
    { ObjectType::VAN, ObjectMajorType::VEHICLE },
    { ObjectType::BUS, ObjectMajorType::VEHICLE },
    { ObjectType::TRUCK, ObjectMajorType::VEHICLE },

    { ObjectType::CYCLIST, ObjectMajorType::BICYCLE },
    { ObjectType::MOTORCYCLIST, ObjectMajorType::BICYCLE },
    { ObjectType::TRICYCLIST, ObjectMajorType::BICYCLE },

    { ObjectType::PEDESTRIAN, ObjectMajorType::PEDESTRIAN },

    { ObjectType::TRAFFICCONE, ObjectMajorType::UNKNOWN_UNMOVABLE },
    { ObjectType::UNKNOWN_MOVABLE, ObjectMajorType::UNKNOWN_MOVABLE },
    { ObjectType::UNKNOWN_UNMOVABLE, ObjectMajorType::UNKNOWN_UNMOVABLE },
    { ObjectType::SAFETY_TRIANGLE, ObjectMajorType::UNKNOWN_UNMOVABLE },
    { ObjectType::BARRIER_DELINEATOR, ObjectMajorType::UNKNOWN_UNMOVABLE },
    { ObjectType::BARRIER_WATER, ObjectMajorType::UNKNOWN_UNMOVABLE },
    { ObjectType::ANIMAL, ObjectMajorType::UNKNOWN_UNMOVABLE },

    { ObjectType::MAX_OBJECT_TYPE, ObjectMajorType::MAX_OBJECT_TYPE },
};

struct Point2f {
    float x = 0;
    float y = 0;
};

struct Point3f {
    float x = 0;
    float y = 0;
    float z = 0;
};

struct Point3d {
    double x = 0;
    double y = 0;
    double z = 0;
};

struct Box2f {
    float Width() const
    {
        return right_bottom.x - left_top.x;
    }
    float Height() const
    {
        return right_bottom.y - left_top.y;
    }

    Point2f left_top;
    Point2f right_bottom;
};

struct SizeShape {
    float length = 0;
    float width = 0;
    float height = 0;
};

struct CubeBox2f {
    Point2f pts8[8];
};

enum class TriStatus {
    UNKNOWN = 0,
    TRUE = 1,
    FALSE = 2,
};

struct SegGroundPlaneParams {
    double range_max_x = 0.0;
    double range_max_z = 0.0;
    double range_min_x = 0.0;
    double range_min_z = 0.0;
    double seg_size = 0.1;
    double seg_radius = 5.0;
    int min_cal_points = 100;
};

}
